package com.rgs.gateway.web.common.design.sign.factory;

import com.rgs.gateway.web.common.design.sign.strategy.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author RenGaoshuai
 * @date 2024/7/1 16:53
 * @description 工厂模式
 */
public class GatewaySignFactory {

    private Map<Integer, GatewaySignStrategy> gatewaySignMap;


    public GatewaySignFactory() {
        List<GatewaySignStrategy> strategys = new ArrayList<GatewaySignStrategy>();

        strategys.add(new CommonGatewaySignStrategy());
        strategys.add(new DataGatewaySignStrategy());
        strategys.add(new SimuAiGatewaySignStrategy());
        strategys.add(new SimuGatewaySignStrategy());

        gatewaySignMap = strategys.stream().collect(Collectors.toMap(GatewaySignStrategy::getSignType, q -> q));

    }


    public static class Holder {
        public static GatewaySignFactory instance = new GatewaySignFactory();
    }

    public static GatewaySignFactory getInstance() {
        return Holder.instance;
    }

    public GatewaySignStrategy getSignType(int signType) {
        return gatewaySignMap.get(signType);
    }
}
